The Universal Serial Bus (USB) is a popular industry standard that defines the cables, connectors, and communications protocols used in a bus for physically connecting electronic devices to one another to facilitate both communications and the provision of power. Generally speaking the USB approach presumes that one such device will serve as the so-called A-device host (and hence source power and direct the communication activity) while the other device serves in the so-called B-device function mode (and hence receives power and otherwise responds to the host).
USB On-The-Go, often abbreviated USB OTG, is a specification that allows USB devices such as digital audio players and mobile phones to act as a host and to allow other USB devices (such as a USB flash drive, mouse, or keyboard) to be attached thereto. Unlike with conventional USB systems, USB OTG devices can drop the hosting role and act in the function mode when attached to another host. This approach can therefore be used, for example, to allow a mobile phone to act as host for a flash drive and read its contents but then act as a flash drive when plugged into a host computer and allow the host to read off the new content. To serve in these regards the USB On-The-Go and Embedded Host Supplement to the USB 2.0 specification introduced three new protocols, the Attach Detection Protocol (ADP), the Session Request Protocol (SRP), and the Host Negotiation Protocol (HNP).
ADP allows an OTG device to determine attachment status in the absence of power on the USB bus. This enables both insertion-based behavior and the possibility for a device to display attachment status. ADP does this by providing for periodic measurement of capacitance on the USB port to determine whether there is another device or a dangling cable attached, or nothing attached. When a change in capacitance, large enough to indicate device attachment is detected then an A-device will provide power to the USB bus and look for device connection. A B-device will generate SRP and wait for the USB bus to become powered.
SRP allows both communicating devices to control when the link's power session is active (in standard USB, only the host is capable of doing so). SRP therefore allows finer control over power consumption. For example, the OTG or Embedded host can leave the USB link unpowered until the peripheral (which can be an OTG or standard USB device) asks for power thereby helping to preserve battery capacity.
For its part, HNP allows the two devices to exchange their host/function roles provided both are OTG dual-role devices. By using HNP for reversing host/peripheral roles, the USB OTG device is capable of acquiring control of data-transfer scheduling. Thus, any OTG device is capable of initiating data-transfer over USB OTG bus. The latest version of the supplement also introduced the idea of HNP polling whereby the device having the host role periodically polls the B-device, during an active session, to determine whether the latter wishes to become a host.
The A-device and B-device terminology mentioned above is actually a bit more nuanced than first suggested. This terminology defines which side supplies power to the link, and which is initially the host. The OTG A-device is a power supplier and the OTG B-device is a power consumer. The default link configuration is that the A-device acts as USB Host and the B-device is a USB peripheral that assumes the function role. The host and peripheral modes may be exchanged later by using HNP. Because every OTG controller supports both roles, they are often called “Dual-Role” controllers rather than “OTG controllers”.
This expanded functionality, unfortunately, comes at a price—these new OTG protocols cannot pass through a standard USB hub since they are based on physical electrical-signaling. Compatibility, in turn, requires more complex (and expensive) connectors and controllers. As a result, implementation and usage of OTG-capable devices remains relatively weak.